package String_test;

public class reverse {
}

/**
 * 仅仅翻转字母
 */
class Solution {
    public String reverseOnlyLetters(String s) {
        char[] charArray = s.toCharArray();
        int left = 0;
        int right = charArray.length-1;

        while (left < right){
            while (charArray[left] == '-'){
                left++;
            }
            while (charArray[right] == '-'){
                right--;
            }
            //交换
            char temp =charArray[left];
            charArray[left] = charArray[right];
            charArray[right] = temp;
        }
        String finalArray = new String(charArray);
        return  finalArray;
    }
}
